JBoss Community Archive (Read Only)

ModeShape 2.7

MP3 Sequencer

Another sequencer that is included in ModeShape is the modeshape-sequencer-mp3 sequencer project. This sequencer processes MP3 audio files added to a repository and extracts the ID3 metadata for the file, including the track's title, author, album name, year, and comment. After extracting this information from the audio files, the sequencer then writes this structure into the repository, where it can be further processed, analyzed, searched, navigated, or referenced.

ExampleThis sequencer generates a node with the name mp3:metadata below the sequencing target. That is if the ouputtingTo property from the sequencer configuration is /mp3s/LivinOnAPrayer, the sequencer will output a node to /mp3s/LivinOnAPrayer/mp3:metadata.

<mp3:metadata jcr:primaryType="mp3:metadata"
              jcr:mixinTypes="mode:derived"
              mode:derivedAt="2011-05-13T13:12:03.925Z"
              mode:derivedFrom="/files/LOP.mp3"
              mp3:title="Livin' on a Prayer"
              mp3:author="Bon Jovi"
              mp3:album="Slippery When Wet"
              mp3:year="1986"
              mp3:comment="Rock 'n' roll!" />

The CND used by this sequencer is provided below.

[mp3:metadata] > nt:unstructured, mix:mimeType
  - mp3:title (string)
  - mp3:author (string)
  - mp3:album (string)
  - mp3:year (long)
  - mp3:comment (string)

To use this sequencer, simply include the modeshape-sequencer-mp3 JAR and the JAudioTagger library in your application and configure the JcrConfiguration to use this sequencer using something similar to:

JcrConfiguration config = ...

config.sequencer("MP3 Sequencer")
      .usingClass("org.modeshape.sequencer.mp3.Mp3MetadataSequencer")
      .loadedFromClasspath()
      .setDescription("Sequences MP3 files to extract the ID3 tags of the audio file")
      .sequencingFrom("//(*.mp3[*])/jcr:content[@jcr:data]")
      .andOutputtingTo("/mp3s/$1");
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:03:08 UTC, last content change 2011-12-06 22:21:19 UTC.